package com.cn.wanxi.util.service;

import com.cn.wanxi.util.dao.NavDao;
import com.cn.wanxi.util.model.NavModel;

import java.util.ArrayList;
import java.util.List;

public class NavService {
    //        数组的定义--方式？ 动态定义  静态定义
    public NavModel[] getNavModels() {
        //定义了一个有6个元素的数组，里面的数据为空
        NavModel[] navModels = new NavModel[6];

        NavDao navDao = new NavDao();
// 想要拿到数组里面的值  需要进行遍历
//        for (int i = 0; i < navDao.getHrefs().length; i++) {
//            NavModel navModel = new NavModel();
//            navModel.setHref(navDao.getHrefs()[i]);
//            navModel.setTitle(navDao.getTitles()[i]);
//            navModels[i] = navModel;
//        }
//        navModels[0] = navModel;
//        navModels[1] = navModel;
//        navModels[2] = navModel;
//        navModels[3] = navModel;
//        navModels[4] = navModel;
//        navModels[5] = navModel;

        return navModels;
    }

    public List<NavModel> getNavModelList() {
        List<NavModel> list = new ArrayList<>();
//        要对list进行赋值
//       model :list
        NavDao navDao = new NavDao();
        List<String> hrefs = navDao.getHrefs();
        List<String> titles = navDao.getTitles();
//        for (String href : hrefs
//        ) {
        for (int i = 0; i < hrefs.size(); i++) {
            NavModel navModel = new NavModel();
            navModel.setHref(hrefs.get(i));
            navModel.setTitle(titles.get(i));
            list.add(navModel);
        }
        return list;

    }
}
